package com.zjut.spider;

import com.zjut.dao.ProductMapper;
import com.zjut.pojo.Product;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

/**
 * Created by Ryan on 2016/10/25.
 */

public class MyBatisPipeline4JDDBD implements Pipeline {

    private ProductMapper productMapper;

    public MyBatisPipeline4JDDBD(ProductMapper productMapper) {
        this.productMapper = productMapper;
    }

    @Override
    public void process(ResultItems resultItems, Task task) {
        Product product= (Product)resultItems.get("Product");
        if (product != null) {
            productMapper.insertSelective(product);
        }
    }
}
